<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>录取情况查询</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="<%=basePath%>layui/css/layui.css" media="all">
  
<script src="<%=basePath%>/js/jquery-3.2.1.min.js"></script>
</head>
<body>
<form class="layui-form">
 	 <div style="margin-left:10px; margin-right:10px;">
		<table id="userlist" lay-filter="userlist"></table>
	 </div>
</form>

<script type="text/html" id="caozuo">
  <a class="layui-btn layui-btn-xs" lay-event="edit">题目详情信息</a>
  <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">取消选题</a>
</script>

</body>


<script src="<%=basePath%>/js/vue.min.js"></script>
<script src="<%=basePath%>/layui/layui.js" charset="utf-8"></script>
<script>
layui.use('table', function() {
	var table = layui.table;
	
	table.render({
		elem : '#userlist',
	    height:450,
		// width: 800,
		page: true,
		limit: 10,
		url : '/bysjxksys/student/ck_csbj',
		response: {
			statusName: 'code'   //规定数据状态的字段名称，默认：code
			,statusCode: 0       //规定成功的状态码，默认：0
			,msgName:   'msg'    //规定状态信息的字段名称，默认：msg
			,countName: 'count'  //规定数据总数的字段名称，默认：count
			,dataName:  'data'   //规定数据列表的字段名称，默认：data
		},
		cols: [[ //标题栏
			{field: '', title: '序号', width:40, type:'numbers'}
		   ,{field: 'sbjName', title: '选题名称', align:'center',templet:'<div>{{d.subject ? d.subject.sbjName: ""}}</div>'}
		   ,{field: 'sbjType', title: '选题类型', align:'center',templet:'<div>{{d.subject ? d.subject.sbjType: ""}}</div>'}
		   ,{field: 'csState', title: '审核状态', align:'center'}
		   ,{title : '操作', toolbar: '#caozuo', align: 'center'}
		]],
        id : "userlistTable"
    });

    table.on('tool(userlist)', function(obj){
    	var data = obj.data;
    	if(obj.event === 'edit'){
    		localStorage.setItem('tId',data.tId);     
    		//console.log(data.sbjId);
    		layer.open({
                type: 2,
                title : '毕业设计题目信息',
                //skin: 'layui-layer-rim', //加上边框
                area: ['800px', '600px'], //宽高
                content:'/bysjxksys/pages/student/SubjectInfrom.jsp',
                btn:['确定','取消'],
                yes:function(index,layero){
                    var formSubmit = layer.getChildFrame('form',index);
                    var submited = formSubmit.find('button')[0];
                    submited.click();
                    location.reload();
                }
            });
    	}else if(obj.event === 'del'){
            layer.confirm('确定取消该毕业设计题目！',{icon:3, title:'提示信息'},function(index){
                var param = {};
                param.sbjId = data.sbjId;

                $.ajax({
                    type:"GET",
                    url:"/bysjxksys/student/stu_csbjDel",
                    dataType:"json",
                    //contentType:"application/json",
                    data:param,
                    success: function(data){
                        layer.close(index);
                        if(data.code==1){
                            alert(data.msg);
                        }else{
                            layer.msg("取消选题成功！", {
                                time: 1000,
                                end: function(){
                                    window.location.reload();
                                }
                            });
                        }
                    },
                    error: function(data, type, err){
                        layer.close(index);
                        console.log(type);
                        console.log(err);
                    }
                });
            });
        }

   	});

    $(".search_btn").on("click",function(){
		table.reload("userlistTable",{
			page: {
				curr: 1 //重新从第 1 页开始
			},
		});
	});
});

function add(){
    layer.open({
        type: 2,
        title : '新增题目',
        //skin: 'layui-layer-rim', //加上边框
        area: ['800px', '600px'], //宽高
        content:'/bysjxksys/pages/teacher/addSubject.jsp',
        btn:['确定','取消'],
        yes:function(index,layero){
            var formSubmit = layer.getChildFrame('form',index);
            var submited = formSubmit.find('button')[0];
            submited.click();
            location.reload();
        }
    });
}
</script>
</html>